package com.quanyue.haircut.shop.mapper;

import com.quanyue.haircut.domain.entity.Card;
import com.quanyue.haircut.domain.entity.User;
import com.vhuomai.mybatis.mapper.auto.AutoMapper;
import com.vhuomai.mybatis.mapper.page.Page;
import com.vhuomai.mybatis.mapper.page.PageRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CardMapper extends AutoMapper <Card, Integer> {
    List <Card> findByUserValid(@Param("userId") Integer userId);

    Card findByUserAndShopValid(@Param("userId") Integer userId, @Param("shopId") Integer shopId);

    Card findByCardNo(@Param("cardNo") String cardNo);

    @Select("select u.* from qy_card c "
            + "left join qy_user u on u.id = c.user_id "
            + "where c.shop_id = #{shopId} and c.del_flag = false")
    Page <User> findUserByShop(@Param("request") PageRequest request, @Param("shopId") Integer shopId);

    Page<Card> findCardByShop(@Param("request") PageRequest request, @Param("shopId") Integer shopId);
}
